Skip to content

Conversation

@iamdharmesh
Copy link
Contributor

Summary

We recently received a report from a customer that a subscription renewal fails with a fatal error when HPOS is enabled. Upon investigation, we found that this was caused by another extension on the site setting a WC_Cart object in the subscription's metadata, leading to a fatal error being thrown from our do_not_copy_order_meta function.

While storing objects in metadata is unusual, as part of defensive programming, it is better to add a check to ensure the data is valid before verifying whether a specific key exists. This PR makes a minor change to ensure that $meta is an array before checking if $meta['meta_key'] is set.

Fatal error:

ERROR scheduled action 11656188 (subscription payment) failed to finish processing due to the following exception: Cannot use object of type WC_Cart as array in /wp-content/plugins/woocommerce-gateway-paypal-powered-by-braintree/vendor/skyverge/wc-plugin-framework/woocommerce/payment-gateway/integrations/class-sv-wc-payment-gateway-integration-subscriptions.php:450

UI Changes

N/A

QA

  1. Purchase a subscription product.
  2. Add any object to the subscription's metadata.
  3. Go to Edit Subscription, select "Process Renewal" from the order actions, and submit.
  4. Verify that the subscription renewal is processed successfully without a fatal error.

Before merge

  • I have confirmed these changes in each supported minor WooCommerce version

…al when the object is stored in the subscription's metadata.
@nmolham-godaddy nmolham-godaddy self-requested a review February 10, 2025 03:31
@nmolham-godaddy nmolham-godaddy changed the base branch from master to release/5.15.4 February 10, 2025 03:39
Copy link
Contributor

@nmolham-godaddy nmolham-godaddy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty good observation, and solid code suggestion. I just added below a tiny additional suggestion for a more stricter data comparison in the array values.

@jeffpaul
Copy link

@nmolham-godaddy back to you for review

@nmolham-godaddy nmolham-godaddy merged commit 48080d5 into godaddy-wordpress:release/5.15.4 Feb 18, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants